<?php
           
   /**
   *team_problem表类
   *存放队伍做题信息做题信息
   *@author kinet 380511703@qq.cn
   *@time 2010-4-18 to 2010-4-23    
   *@version 1.1
   */
require_once('db_obj.class.php') ;   
class team_problem extends db_obj{ 
          public $vdb;
          public function __construct( $db ){         
                 parent::__construct( $db , 'team_problem' );
                 $this->vdb=$db; 
                 $this->add('team_no', '');                  
                 $this->add('problem_no', '');                     
                 $this->add('lasttime','');
                 $this->add('subtimes','');
                 $this->add('stat','');  
          }
          /**
          * 用于判断改team_problem是否已存在
          * 
          * @param队伍号
          * @param题号
          */
          public function load($team_no,$problem_no){
                   $res=$this->vdb->query( "SELECT * FROM team_problem
                                             WHERE team_no=".$team_no." 
                                                        and
                                                    problem_no=".$problem_no); 
                  if ( !$res ){ 
                        return false ;
                       
                  } 
                  if($rows=$res->fetchRow(MDB2_FETCHMODE_ASSOC )){
                      $this->set('team_no',$team_no);
                      $this->set('problem_no',$problem_no);
                      $this->set('lasttime',$rows['lasttime']);
                      $this->set('subtimes',$rows['subtimes']); 
                      $this->set('stat',$rows['stat']);
                      return true;                      
                  }
                  else {
                      return false;   
                  }
          }
           public function update(){
                 $sql="update team_problem 
                                   set lasttime='".$this->get('lasttime')."',
                                   stat='".$this->get('stat')."',
                                   subtimes=".$this->get('subtimes')."
                                   where 
                                   team_no=".$this->get('team_no')."
                                    and 
                                   problem_no=".$this->get('problem_no');  
                 $this->vdb->query( $sql );       
           }
           public function del(){
               $this->vdb->query( "DELETE FROM team_problem 
                                   WHERE problem_no =".$this->get('problem_no')." 
                                     and
                                     team_no=".$this->get('team_no') );
           }
    
 }
